import { put, takeEvery } from 'redux-saga/effects';
import { GET_INIT_LIST } from './actionTypes';
import { getInitAction } from './actionCreator';
import axios from 'axios';

function* getInitList() {

	try {
		const res = yield axios.get('/list.json');
  	const action = getInitAction(res.data);
 		yield put(action);

	}	catch(e) {
		console.log('error');
	}
}

function* mySaga() {
  yield takeEvery(GET_INIT_LIST, getInitList);
}

export default mySaga;